package log;

import java.util.Date;

import org.apache.log4j.Logger;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

@Component
@RequestMapping("/lottery")
public class LogTestControl {
	private static final Logger LOGGER = Logger.getLogger(LogTestControl.class);
	
	@ResponseBody
	@RequestMapping(value="/log")
	public String add() throws Exception {
		for (int i = 0; i < 10; i++) {
			LOGGER.error("Info log [" + i + "].");
			Thread.sleep(500);
		}
		return "success";
	}
	
	@ResponseBody
	@RequestMapping(value="/addError")
	public String addError(){
		LOGGER.error("Error log [" + new Date() + "]");
		LOGGER.info("Info log [" + new Date() + "]");
		System.out.print("error!!!");
		return "success";
	}
}
